home *** CD-ROM | disk | FTP | other *** search
/ Amiga Collections: MegaDisc / MegaDisc 17 (1990)(MegaDisc Digital Publishing)(AU)[WB].zip / MegaDisc 17 (1990)(MegaDisc Digital Publishing)(AU)[WB].adf / Hardware / HDPREP.BAS < prev    next >
BASIC Source File  |  1990-06-27  |  18KB  |  748 lines

  1. DEFLNG a
  2. DEFINT b-z
  3.  
  4. DIM cfarray(6)
  5. DIM result(8) :         REM Result after error
  6. DIM databuffer(512)
  7. DIM errortrack(100) :   REM Error list
  8.  
  9. DIM DriveName$(32) :    REM Manufactures Name
  10. DIM DriveCyl(32) :      REM Number of Cylinders
  11. DIM DrivePre(32) :      REM 1st Cylinder for Precomp.
  12. DIM DriveHead(32) :     REM Number of Heads
  13. DIM DriveStep(32) :     REM Steprate
  14.  
  15. numcyl = 0 :            REM Working parameters for drive
  16. redcurr = 0
  17. wrtprecomp = 0
  18. numhead = 0
  19. steprate = -1
  20. dname$ = ""
  21. ver$ = "V3.04 21/04/90"
  22.  
  23. startcyl = 0
  24. werror = 0
  25.  
  26. addr = 15599169& :' $EE0641 : REM Start address for XT Controller
  27. adrstatus = addr+2
  28. adrselect = addr+4
  29. adrmask   = addr+6
  30.  
  31. REM =========================================================
  32.  
  33. MFMDrives:
  34. DATA 24
  35. DATA "Maxtor XT1140",         918,  918, 15, 1
  36. DATA "CMI 6426",              640,  256,  4, 1
  37. DATA "Rodime 352",            306,  306,  4, 1
  38. DATA "Microscience HH312",    306,  306,  4, 1
  39. DATA "Seagate ST4026",        615,  300,  4, 1
  40. DATA "Cynthia 570",           987,  987,  7, 1
  41. DATA "Vertex V170",           987,  987,  7, 1
  42. DATA "Seagate ST4038",        733,  300,  5, 1
  43. DATA "Seagate ST213",         612,  256,  2, 1
  44. DATA "Miniscribe 3425",       612,  128,  4, 1
  45. DATA "Quantum Q540",          512,  256,  8, 1
  46. DATA "Seagate ST4051",        977,  300,  5, 1
  47. DATA "CMI 342",               612,  256,  4, 1
  48. DATA "Seagate ST225",         612,  256,  4, 1
  49. DATA "CDC 9415-36",           697,  256,  5, 1
  50. DATA "CMI 3212",              612,  128,  2, 1
  51. DATA "Miniscribe 3012/3212",  612,  128,  2, 1
  52. DATA "CMI 6640",              640,  256,  6, 1
  53. DATA "Tulin 240",             640,  256,  6, 1
  54. DATA "CMI 5412",              306,  128,  4, 1
  55. DATA "Lapine 3522",           306,  128,  4, 1
  56. DATA "Otari 514",             306,  128,  4, 1
  57. DATA "Seagate ST412/ST212",   306,  128,  4, 1
  58. DATA "Shugart 712",           306,  128,  4, 1
  59.  
  60. RLLDrives:
  61. DATA 21
  62. DATA "Atasi 3085",           1024, 1024,  8, 1
  63. DATA "Miniscribe 8438",       612,  612,  4, 1
  64. DATA "Microscience HH330",    612,  612,  4, 1
  65. DATA "Microscience HH738",    612,  612,  4, 1
  66. DATA "Peripheral Tech 357R",  615,  615,  6, 1
  67. DATA "Lapine LT300",          616,  616,  4, 1
  68. DATA "Priam V170",            987,  987,  7, 1
  69. DATA "Priam V185",           1166, 1166,  7, 1
  70. DATA "Priam 514",            1224, 1224, 11, 1
  71. DATA "Priam 519",            1224, 1224, 15, 1
  72. DATA "Seagate ST251R",        820,  820,  4, 1
  73. DATA "Seagate ST277R",        820,  820,  6, 1
  74. DATA "Seagate ST4077R",      1024, 1024,  5, 1
  75. DATA "Seagate ST4144R",      1024, 1024,  9, 1
  76. DATA "Toshiba MK53FB",        830,  830,  5, 1
  77. DATA "Toshiba MK54FB",        830,  830,  7, 1
  78. DATA "Toshiba MK56FB",        830,  830, 10, 1
  79. DATA "Seagate ST238R",        615,  615,  4, 1
  80. DATA "Miniscribe 3438",       615,  615,  4, 1
  81. DATA "Fujitsu M2226D",        615,  615,  6, 1
  82. DATA "Fujitsu M2227D",        615,  615,  8, 1
  83.  
  84. REM =========================================================
  85.  
  86. 'WINDOW 1,, (0,0)-(637,186)
  87.  
  88. CLS
  89. PRINT "Low Level Format program ";ver$;"    Controller address $";hex$(addr)
  90. COLOR 3 : BEEP
  91. PRINT "Warning !!! All Data will be erased on hard disk ...If in doubt ^C or reboot."
  92. PRINT 
  93. COLOR 1
  94.  
  95. WHILE UCASE$(type$) <> "MFM" AND UCASE$(type$) <> "RLL"
  96.   LOCATE 4, 1
  97.   INPUT "Enter Controller type (MFM or RLL) "; type$
  98. WEND
  99. IF UCASE$(type$) = "RLL" THEN
  100.   numsec = 26
  101.   RESTORE RLLDrives
  102. ELSE
  103.   numsec = 17
  104.   RESTORE MFMDrives
  105. END IF
  106.  
  107. READ imax : REM Number of drives in MFM/RLL lists
  108. FOR i=0 TO imax-1
  109.   READ DriveName$(i), DriveCyl(i), DrivePre(i), DriveHead(i), DriveStep(i)
  110. NEXT i
  111.  
  112. unit = -1
  113. WHILE unit < 0 OR unit > 1
  114.   LOCATE 6, 1
  115.   INPUT "Enter unit to be formatted (0..1) ",unit
  116. WEND
  117. lun = unit * 32 ' lun is logical unit
  118.  
  119. CALL SelectDriveType(imax)
  120. CALL GetDriveData
  121. endcyl = numcyl
  122.  
  123. CLS
  124. PRINT USING "Drive #: & has #### Cylinders  ## Heads"; unit, dname$, numcyl, numhead
  125. CALL Fixdefect
  126.  
  127. lasttrack = (numcyl * numhead) - 1 : REM Last available track
  128. maxtrack = lasttrack
  129.  
  130. PRINT : BEEP
  131. PRINT  "Format starts at cylinder "; startcyl; "and ends at "; lasttrack\numhead
  132. PRINT  "Ready to start the Format? (Y/N) ";
  133. jn$ = INPUT$(1)
  134. IF UCASE$(jn$) <> "Y" THEN END
  135.  
  136.  
  137. CALL SetChar : REM Set Drive Characteristics
  138.  
  139. CLS : PRINT "Starting..."
  140. PRINT "Recalibrating the drive"
  141. CALL Recalibrate
  142. PRINT "Formatting"
  143. CALL formatdrive(startcyl)
  144. PRINT "Format complete"
  145.  
  146.  
  147. IF defect THEN
  148.   PRINT : PRINT  "Defects detected, allocating spare sectors :"
  149.   FOR i=0 TO defect-1
  150.     defectCyl = errortrack(i)\numhead
  151.     defectHead = errortrack(i) MOD numhead
  152.     NewCyl = lasttrack\numhead
  153.     NewHead = lasttrack MOD numhead
  154.     CALL AltTrack( defectCyl, defectHead, NewCyl, NewHead, lasttrack)
  155.   NEXT i
  156. END IF
  157.  
  158.  
  159. IF (lasttrack MOD numhead) THEN
  160.   endcyl = (lasttrack\numhead)-1
  161. ELSE
  162.   endcyl = lasttrack\numhead
  163. END IF
  164.  
  165. PRINT : PRINT  "Verifying the format"
  166.   PRINT "CYLINDER      HEAD"
  167. FOR cyl=startcyl TO endcyl
  168.   FOR head=0 TO numhead-1
  169.     LOCATE ,1
  170.     PRINT   cyl, head;
  171.     CALL check(cyl, head)
  172.     WHILE werror <> 0
  173.       PRINT  " ERROR ";
  174.       FOR i=0 TO 4 : PRINT  HEX$(result(i)); " "; : NEXT
  175.       PRINT
  176.       werror = 0
  177.       NewCyl = lasttrack\numhead
  178.       NewHead = lasttrack MOD numhead
  179.       defect = defect + 1
  180.       CALL AltTrack( cyl, head, NewCyl, NewHead, lasttrack)
  181.       IF (lasttrack MOD numhead) THEN endcyl = (lasttrack\numhead)-1 ELSE endcyl = lasttrack\numhead
  182.     WEND
  183.   NEXT head
  184. NEXT cyl
  185. PRINT  : PRINT  "Verification finished."
  186.  
  187. Rem New drive data will be written to sector 0 on cuurent drive
  188. REM this is used by the driver to recognise for initialisation.
  189. CALL SaveDriveData(endcyl+1, redcurr, wrtprecomp, numhead, steprate)
  190.  
  191. IF lasttrack < maxtrack THEN
  192.    PRINT : PRINT "ATTENTION: Drives defective sectors have altered total usable cylinders"
  193. END IF
  194.  
  195. TOENDORNOT:
  196. LOCATE ,1
  197.    COLOR 3 : PRINT "The high cylinder number is "; endcyl : COLOR 1
  198.    PRINT "This value is for the HighCyl in the mountlist"
  199.    PRINT "(This is the end of the Program)"
  200.   PRINT  "TO QUIT TYPE Q ";
  201.     jn$ = INPUT$(1)
  202.   IF UCASE$(jn$) <> "Q" THEN TOENDORNOT
  203. END
  204.  
  205.  
  206. REM =========================================================
  207.  
  208.  
  209. SUB AltTrack( cyl, head, altcyl%, althead%, lasttrack ) STATIC
  210. SHARED numhead
  211.  
  212. form$ = "Creating Alternate Track : ####_/## ==> ####_/##"
  213. defecttrack = cyl*numhead + head
  214.  
  215. IF defecttrack < lasttrack THEN
  216.    PRINT USING form$; cyl, head, altcyl%, althead%
  217.    CALL AssignAltTrack( cyl, head, altcyl%, althead%)
  218. END IF
  219. lasttrack = lasttrack - 1
  220.  
  221. END SUB
  222.  
  223.  
  224.  
  225. REM =========================================================
  226. SUB waitready STATIC
  227. SHARED adrstatus
  228.  
  229. WHILE (PEEK(adrstatus) AND 1) <> 1 : WEND
  230. END SUB
  231.  
  232.  
  233.  
  234.  
  235. REM =========================================================
  236. SUB sendcommand STATIC
  237. SHARED addr, adrselect,cfarray()
  238.  
  239. POKE adrselect,0
  240. FOR i=0 TO 5
  241.   waitready
  242.   POKE addr, cfarray(i)
  243. NEXT
  244.  
  245. END SUB
  246.  
  247.  
  248.  
  249. REM =========================================================
  250. SUB readresult STATIC
  251. SHARED addr, adrstatus, result()
  252.  
  253. FOR i=0 TO 4
  254.   waitready
  255.   IF i=3 THEN
  256.      result(i) = result(i)+ PEEK(addr)
  257.   ELSE
  258.      result(i) = PEEK(addr)
  259.   END IF
  260.   IF i=2 THEN
  261.      IF result(i) >= 64 THEN
  262.        result(i+1) = (result(i) / 64) * 256
  263.      ELSE
  264.        result(i+1) = 0
  265.      END IF
  266.   END IF
  267. NEXT i
  268. END SUB
  269.  
  270.  
  271. REM =========================================================
  272. SUB errorcheck STATIC
  273. SHARED addr, adrstatus, cfarray(), werror, lun
  274.  
  275. werror = 0
  276. waitready
  277. status = PEEK(addr)
  278. IF (status AND 2) <> 0 THEN
  279.   werror = 1
  280.   cfarray(0) = 3
  281.   cfarray(1) = 0 OR lun
  282.   cfarray(2) = 0
  283.   cfarray(3) = 0
  284.   cfarray(4) = 0
  285.   cfarray(5) = 0
  286.   sendcommand
  287.   readresult
  288.   PRINT " Error #"; HEX$(cfarray(0) AND &H30)
  289. END IF
  290.  
  291. END SUB
  292.  
  293.  
  294. REM =========================================================
  295. SUB SetChar STATIC
  296. SHARED cfarray(), addr, adrstatus, adrmask, lun, numcyl, numhead
  297.  
  298. DIM charac(8)
  299.  
  300. charac(0) = ((numcyl-2) \ &HFF) AND &H3
  301. charac(1) = (numcyl-2) MOD &HFF
  302. charac(2) = numhead AND &H1F
  303. charac(3) = charac(0)      : ' reduced write current
  304. charac(4) = charac(1)
  305. charac(5) = charac(0)      : ' Write precompensation
  306. charac(6) = charac(1)
  307. charac(7) = 0
  308.  
  309. POKE adrstatus, 0 : ' reset
  310. POKE adrmask, 0 : ' Interrupt-Mask 0
  311.  
  312. cfarray(0) = 12
  313. cfarray(1) = 0 OR lun
  314. cfarray(2) = 0
  315. cfarray(3) = 0
  316. cfarray(4) = 0
  317. cfarray(5) = 0
  318. sendcommand
  319. FOR i=0 TO 7
  320.   waitready
  321.   POKE addr, charac(i)
  322. NEXT i
  323. errorcheck
  324.  
  325. ERASE charac
  326. END SUB
  327.  
  328.  
  329. REM =========================================================
  330. SUB formatdrive(startc) STATIC
  331. SHARED cfarray(), lun, interleave, steprate
  332.  
  333. cfarray(0) = 4
  334. cfarray(1) = ((startc\16) AND &H80) OR lun
  335. cfarray(2) = (startc\4) AND &HC0
  336. cfarray(3) = startc AND &HFF
  337. cfarray(4) = interleave AND &H1F
  338. cfarray(5) = steprate AND &H3
  339. sendcommand
  340. errorcheck
  341. END SUB
  342.  
  343.  
  344. REM =========================================================
  345. SUB formattrack(cyl, head) STATIC
  346. SHARED cfarray(),lun, interleave, steprate
  347.  
  348. cfarray(0) = 6
  349. cfarray(1) = ((cyl\16) AND &H80) OR lun OR (head AND &H1F)
  350. cfarray(2) = (cyl\4) AND &HC0
  351. cfarray(3) = cyl AND &HFF
  352. cfarray(4) = interleave AND &H1F
  353. cfarray(5) = steprate AND &H7
  354. sendcommand
  355. errorcheck
  356.  
  357. END SUB
  358.  
  359.  
  360.  
  361. REM =========================================================
  362. SUB formatbadtrack(cyl, head) STATIC
  363. SHARED cfarray(),lun, interleave, steprate
  364.  
  365. cfarray(0) = 7
  366. cfarray(1) = ((cyl\16) AND &H80) OR lun OR (head AND &H1F)
  367. cfarray(2) = (cyl\4) AND &HC0
  368. cfarray(3) = cyl AND &HFF
  369. cfarray(4) = interleave AND &H1F
  370. cfarray(5) = steprate AND &H7
  371. sendcommand
  372. errorcheck
  373.  
  374. END SUB
  375.  
  376.  
  377.  
  378. REM =========================================================
  379. SUB AssignAltTrack(cyl, head, altcyl%, althead%) STATIC
  380. SHARED cfarray(),lun, interleave, steprate, addr, adrstatus
  381.  
  382. DIM atdat%(4)
  383.  
  384. IF (cyl < startcyl OR altcyl% < startcyl) THEN
  385.      PRINT "Cylinder is now : "; cyl, altcyl
  386.      STOP
  387. END IF
  388. cfarray(0) = &H11
  389. cfarray(1) = ((cyl\16) AND &H80) OR lun OR (head AND &H1F)
  390. cfarray(2) = (cyl\4) AND &HC0
  391. cfarray(3) = cyl AND &HFF
  392. cfarray(4) = interleave AND &H1F
  393. cfarray(5) = steprate AND &H7
  394.  
  395. atdat%(0) = ((altcyl%\16) AND &H80) OR (althead% AND &H1F)
  396. atdat%(1) = (altcyl%\4) AND &HC0
  397. atdat%(2) = altcyl% AND &HFF
  398. atdat%(3) = 0
  399.  
  400. sendcommand
  401. status = PEEK(adrstatus)
  402. IF (status AND 4) = 0 THEN
  403.   FOR i=0 TO 3
  404.     waitready
  405.     POKE addr, atdat%(i)
  406.   NEXT i
  407. END IF
  408. errorcheck
  409.  
  410. ERASE atdat%
  411. END SUB
  412.  
  413.  
  414.  
  415. REM =========================================================
  416. SUB seek(track) STATIC
  417. SHARED cfarray(), lun, steprate
  418.  
  419. cfarray(0) = &HB
  420. cfarray(1) = ((track\16) AND &H80) OR lun
  421. cfarray(2) = (track\4) AND &HC0
  422. cfarray(3) = track AND &HFF
  423. cfarray(4) = 0
  424. cfarray(5) = steprate AND &H7
  425. sendcommand
  426. errorcheck
  427. END SUB
  428.  
  429.  
  430. REM =========================================================
  431. SUB Recalibrate STATIC
  432. SHARED cfarray(), lun, steprate
  433.  
  434. cfarray(0) = &HB
  435. cfarray(1) = lun
  436. cfarray(2) = 0
  437. cfarray(3) = 0
  438. cfarray(4) = 0
  439. cfarray(5) = steprate AND &H7
  440. sendcommand
  441. errorcheck
  442. END SUB
  443.  
  444.  
  445. REM =========================================================
  446. SUB check(track, head) STATIC
  447. SHARED cfarray(), numsec, lun, steprate
  448.  
  449. cfarray(0) = 5
  450. cfarray(1) = 0 OR lun
  451. cfarray(2) = (track\4) AND &HC0
  452. cfarray(3) = track AND &HFF
  453. cfarray(4) = numsec AND &HFF
  454. cfarray(5) = steprate AND &H7
  455. sendcommand
  456. errorcheck
  457. END SUB
  458.  
  459.  
  460.  
  461. REM =========================================================
  462. SUB writesector(cyl, head, sect, buffer(1) ) STATIC
  463. SHARED cfarray(), adrstatus, addr, lun, steprate
  464.  
  465. cfarray(0) = &HA
  466. cfarray(1) = ((cyl\16) AND &H80) OR lun OR head
  467. cfarray(2) = ((cyl \ 4) AND &HC0) OR (sect AND &H3F)
  468. cfarray(3) = cyl AND &HFF
  469. cfarray(4) = 1
  470. cfarray(5) = steprate AND &H7
  471. sendcommand
  472. waitready
  473. status = PEEK(adrstatus)
  474. IF (status AND 4) = 0 THEN
  475.   waitready
  476.   FOR i=0 TO 511
  477.     POKE addr, buffer(i)
  478.   NEXT i
  479. END IF
  480. errorcheck
  481.  
  482. END SUB
  483.  
  484.  
  485. REM =========================================================
  486. SUB readsector(cyl, head, sect, buffer(1) ) STATIC
  487. SHARED cfarray(), adrstatus, addr, lun, steprate
  488.  
  489. cfarray(0) = &H8
  490. cfarray(1) = ((cyl\16) AND &H80) OR lun OR head
  491. cfarray(2) = ((cyl\4) AND &HC0) OR (sect AND &H3F)
  492. cfarray(3) = cyl AND &HFF
  493. cfarray(4) = 1
  494. cfarray(5) = steprate AND &H7
  495. sendcommand
  496. waitready
  497. status = PEEK(adrstatus)
  498. IF (status AND 4) = 0 THEN
  499.   waitready
  500.   FOR i=0 TO 511
  501.     buffer(i) = PEEK(addr)
  502.   NEXT i
  503. END IF
  504. errorcheck
  505.  
  506. END SUB
  507.  
  508.  
  509. REM =========================================================
  510. SUB dumpdata(ddata(1), dlen) STATIC
  511.  
  512. FOR i=0 TO dlen/16
  513.   FOR j=0 TO 15
  514.     h$ = HEX$(ddata(j+16*i))
  515.     WHILE LEN(h$) < 2 : h$ = "0"+h$ : WEND
  516.     PRINT  USING "\\ "; h$;
  517.   NEXT
  518.   PRINT
  519. NEXT
  520.  
  521. END SUB
  522.  
  523.  
  524.  
  525. REM =========================================================
  526.  
  527. REM Enter drive details manually
  528.  
  529. SUB GetDriveData STATIC
  530.  
  531. SHARED numcyl, redcurr, wrtprecomp, numhead, steprate, numsec, interleave
  532.  
  533. CLS
  534. WHILE numcyl < 1 OR numcyl > 2048
  535.   LOCATE 3, 1
  536.   PRINT "HOW MANY CYLINDERS (1..2048)                        ";
  537.   INPUT ;numcyl
  538. WEND
  539. WHILE redcurr < 1 OR redcurr > numcyl
  540.   LOCATE 4, 1
  541.   PRINT USING "Start Reduced write current at cyl(1_._.####) "; numcyl
  542.   LOCATE 4, 53
  543.   INPUT ;redcurr : IF redcurr = 0 THEN redcurr = numcyl
  544. WEND
  545. WHILE wrtprecomp < 1 OR wrtprecomp > numcyl
  546.   LOCATE 5, 1
  547.   PRINT USING "Start Write Precompensation       (1_._.####) "; numcyl
  548.   LOCATE 5, 53
  549.   INPUT ;wrtprecomp : IF wrtprecomp = 0 THEN wrtprecomp = numcyl
  550. WEND
  551.  
  552. WHILE numhead < 1 OR numhead > 16
  553.   LOCATE 6, 1
  554.   INPUT "How many heads                              (1..16) "; numhead
  555. WEND
  556.  
  557. WHILE numsec <> 17 AND numsec <> 26
  558.   LOCATE 7, 1
  559.   INPUT "How many sectors per track               (17 or 26) "; numsec
  560. WEND
  561. WHILE interleave < 1 OR interleave > numsec
  562.   LOCATE 8, 1
  563.   PRINT USING "Sector Interleave Factor            (1_._.##) "; numsec -1;
  564.   INPUT interleave
  565. WEND
  566.  
  567. WHILE steprate <0 OR steprate > 7
  568.   LOCATE 11, 1 : PRINT "Step Rate"
  569.   LOCATE 12, 1 : PRINT " 0 = 3ms     1 = 10µs     2 = 25µs"
  570.   LOCATE 13, 1 : PRINT " 3 = 50µs    4 = 200µs    5 = 70µs"
  571.   LOCATE 14, 1 : PRINT " 6 = 3ms     7 = 3ms"
  572.   LOCATE 15, 1
  573.   INPUT "Step Rate                                    (0..7) ", steprate
  574. WEND
  575.  
  576. END SUB
  577.  
  578.  
  579.  
  580.  
  581. REM =========================================================
  582.  
  583. REM Drive data written at Cylinder 0, Head 0, Sector 0 
  584. SUB SaveDriveData(numcyl, redcurr, wrtprecomp, numhead, steprate) STATIC
  585.  
  586. DIM databuffer%(512)
  587.  
  588. PRINT "Drive data is being stored...";
  589.  
  590. CALL readsector(0, 0, 0, databuffer() )
  591.  
  592. databuffer(18) = numcyl \ 256
  593. databuffer(19) = numcyl MOD 256
  594. databuffer(20) = redcurr \ 256
  595. databuffer(21) = redcurr MOD 256
  596. databuffer(22) = wrtprecomp \ 256
  597. databuffer(23) = wrtprecomp MOD 256
  598. databuffer(24) = numhead \ 256
  599. databuffer(25) = numhead MOD 256
  600. databuffer(26) = steprate \ 256
  601. databuffer(27) = steprate MOD 256
  602.  
  603. FOR i=28 TO 79 : databuffer(i) = 0 : NEXT
  604.  
  605. cks& = 0 : REM Checksum is calculated
  606. FOR i=18 TO 79 STEP 2
  607.   cks& = cks& + 256*databuffer(i) + databuffer(i+1)
  608.   cks& = cks& AND &HFFFF
  609. NEXT
  610.  
  611. cks$ = HEX$(&H55AA-cks&)
  612. WHILE LEN(cks$)<4 : cks$ = "0"+cks$ : WEND
  613. databuffer(16) = VAL("&h"+LEFT$(cks$, 2))
  614. databuffer(17) = VAL("&h"+MID$(cks$, 3))
  615.  
  616. PRINT : PRINT "This is what I wrote !" : CALL dumpdata(databuffer%(), 128)
  617.  
  618. CALL writesector(0, 0, 0, databuffer() )
  619.  
  620. PRINT "All done......."
  621.  
  622. END SUB
  623.  
  624.  
  625.  
  626.  
  627. REM =========================================================
  628.  
  629. SUB SelectDriveType(maxdrive) STATIC
  630.  
  631. SHARED DriveName$(), DriveCyl(), DrivePre(), DriveHead(), DriveStep()
  632. SHARED numcyl, redcurr, wrtprecomp, numhead, steprate, dname$
  633.  
  634. CLS
  635. PRINT "Enter number of drive or RETURN for more else enter 99 to manualy set data "
  636.  
  637. frm$ = "##_. \                        \  #### Cylinder  ## Heads"
  638. ianf = 0
  639.  
  640. WHILE nr <> 99
  641.   iend = ianf + 9
  642.   FOR i=ianf TO iend
  643.     LOCATE i-ianf+3, 1
  644.     IF i < maxdrive THEN
  645.       PRINT USING frm$; i+1, DriveName$(i), DriveCyl(i), DriveHead(i);
  646.     ELSE
  647.       PRINT SPACE$(78);
  648.     END IF
  649.   NEXT i
  650.   LOCATE 16, 1 : INPUT "(Enter number or RETURN (for more drives) "; nr
  651.   IF nr = 0 THEN
  652.     IF iend <= maxdrive THEN
  653.       ianf = iend + 1
  654.     ELSE
  655.       ianf = 0
  656.     END IF
  657.   END IF
  658.   IF nr >= ianf+1 AND nr <= maxdrive THEN
  659.       dname$ = DriveName$(nr-1)
  660.       numcyl = DriveCyl(nr-1)
  661.       redcurr = DrivePre(nr-1)
  662.       wrtprecomp = DrivePre(nr-1)
  663.       numhead = DriveHead(nr-1)
  664.       steprate = DriveStep(nr-1)
  665.       nr = 99
  666.   END IF
  667. WEND
  668.  
  669. END SUB
  670.  
  671.  
  672.  
  673.  
  674. REM =========================================================
  675.  
  676. SUB Fixdefect STATIC
  677.  
  678. SHARED numcyl, numhead, errortrack(), defect
  679.  
  680. a$ = " "
  681. PRINT : PRINT
  682. PRINT  "Input Defects in Cyl,Head,Byte or in Head,Cyl,Byte order (C/H) ";
  683. a$ = INPUT$(1)
  684. cylvorn = UCASE$(a$) = "C"
  685. IF cylvorn THEN
  686.  CHB$ = "C,H,B"
  687. ELSE
  688.  CHB$ = "H,C,B"
  689. END IF
  690.  
  691.  
  692. PRINT : PRINT
  693. PRINT  "Use defect list from error file ?"
  694. PRINT  "Filename for Defect list (or <Return> for Manual entry) ";
  695. LINE INPUT defectfilename$
  696. PRINT
  697. defectfile = 0
  698. IF defectfilename$ <> "" THEN
  699.   PRINT
  700.   OPEN "I", 1, defectfilename$
  701.   defectfile = -1
  702. END IF
  703.  
  704.  
  705. PRINT
  706. PRINT  "Enter as "; CHB$; ", End with RETURN on blank line"
  707. i=0
  708. WHILE a$ <> ""
  709.   PRINT USING "##_.) "; i+1;
  710.   IF defectfile THEN
  711.       LINE INPUT #1,a$
  712.       PRINT a$
  713.   ELSE
  714.       LINE INPUT a$
  715.   END IF
  716.   IF a$ <> "" THEN
  717.     pos1 = INSTR(a$, ",")
  718.     pos2 = INSTR(pos1+1, a$, ",")
  719.     zahl1 = VAL( LEFT$(a$, pos1-1) )
  720.     zahl2 = VAL( MID$(a$, pos1+1, pos2-pos1-1) )
  721.     zahl3 = VAL( MID$(a$, pos2+1) )
  722.     IF cylvorn THEN
  723.       cyl = zahl1
  724.       head = zahl2
  725.     ELSE
  726.       cyl = zahl2
  727.       head = zahl1
  728.     END IF
  729.  
  730.     ok = 1
  731.     IF cyl < 0 OR cyl > numcyl THEN
  732.       PRINT "Cylinder "; cyl; " Number out of range !"
  733.       ok = 0
  734.     END IF
  735.     IF head < 0 OR head > numhead THEN
  736.       PRINT "Head "; head; " Number out of range !"
  737.       ok = 0
  738.     END IF
  739.     errortrack(i) = cyl*numhead + head
  740.   END IF
  741.   IF ok THEN i = i + 1
  742. WEND
  743.  
  744. IF defectfile THEN CLOSE #1
  745. IF i=0 THEN defect=0 ELSE defect=i-1  : REM Number defects
  746.  
  747. END SUB
  748.